/*     */ package com.yss.sofa.cml.design;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;

import javax.print.attribute.standard.MediaSize;

/*     */ 
/*     */ import com.yss.sofa.cml.ColumnGroup;
/*     */ import com.yss.sofa.cml.Document;
/*     */ import com.yss.sofa.cml.Metadata;
/*     */ import com.yss.sofa.cml.Paper;
/*     */ import com.yss.sofa.cml.type.BackgroundSpanEnum;
/*     */ import com.yss.sofa.cml.type.OrientationEnum;
/*     */ 
/*     */ public abstract class BaseDocument
/*     */   implements Document
/*     */ {
/*     */   private static final long serialVersionUID = 1L;
/*     */   private static final int DPI = 72;
/*     */   protected String name;
/*     */   protected OrientationEnum orientation;
/*     */   protected List<DesignStyle> styles;
/*     */   protected Paper paper;
/*     */   protected Metadata metadata;
/*     */   protected Object source;
/*     */   protected int pageWidth;
/*     */   protected int pageHeight;
/*     */   protected int topMargin;
/*     */   protected int rightMargin;
/*     */   protected int leftMargin;
/*     */   protected int bottomMargin;
/*     */   protected DesignBand title;
/*     */   protected DesignBand columnHeader;
/*     */   protected DesignBand detail;
/*     */   protected DesignBand columnFooter;
/*     */   protected DesignBand summary;
/*     */   protected DesignBand background;
/*     */   protected DesignBand pageHeader;
/*     */   protected DesignBand pageFooter;
/*     */   protected BackgroundSpanEnum backgroundSpan;
/*     */   protected ColumnGroup columnGroup;
/*     */ 
/*     */   public BaseDocument(Document base)
/*     */   {
/*  36 */     this();
/*  37 */     this.name = base.getName();
/*  38 */     this.pageWidth = base.getPageWidth();
/*  39 */     this.pageHeight = base.getPageHeight();
/*  40 */     this.orientation = base.getOrientation();
/*  41 */     this.leftMargin = base.getLeftMargin();
/*  42 */     this.rightMargin = base.getRightMargin();
/*  43 */     this.topMargin = base.getTopMargin();
/*  44 */     this.bottomMargin = base.getBottomMargin();
/*     */   }
/*     */ 
/*     */   public BaseDocument() {
/*  48 */     this.styles = new ArrayList();
/*     */   }
/*     */ 
/*     */   public int getPageHeight()
/*     */   {
/*  53 */     return this.pageHeight;
/*     */   }
/*     */ 
/*     */   public int getPageWidth()
/*     */   {
/*  58 */     return this.pageWidth;
/*     */   }
/*     */ 
/*     */   public OrientationEnum getOrientation()
/*     */   {
/*  63 */     return this.orientation;
/*     */   }
/*     */ 
/*     */   public String getName()
/*     */   {
/*  68 */     return this.name;
/*     */   }
/*     */ 
/*     */   public Paper getPaper() {
/*  72 */     if (this.paper == null) {
/*  73 */       synchronized (this) {
/*  74 */         this.paper = Paper.getPaper(MediaSize.ISO.A4);
/*     */       }
/*     */     }
/*  77 */     return this.paper;
/*     */   }
/*     */ 
/*     */   public void setName(String name) {
/*  81 */     this.name = name;
/*     */   }
/*     */ 
/*     */   public void setPageWidth(int pageWidth) {
/*  85 */     this.pageWidth = pageWidth;
/*     */   }
/*     */ 
/*     */   public void setPageHeight(int pageHeight) {
/*  89 */     this.pageHeight = pageHeight;
/*     */   }
/*     */ 
/*     */   public void setOrientation(OrientationEnum orientation) {
/*  93 */     this.orientation = orientation;
/*     */   }
/*     */ 
/*     */   public int getTopMargin()
/*     */   {
/*  98 */     return this.topMargin;
/*     */   }
/*     */ 
/*     */   public int getLeftMargin()
/*     */   {
/* 103 */     return this.leftMargin;
/*     */   }
/*     */ 
/*     */   public int getRightMargin()
/*     */   {
/* 108 */     return this.rightMargin;
/*     */   }
/*     */ 
/*     */   public int getBottomMargin()
/*     */   {
/* 113 */     return this.bottomMargin;
/*     */   }
/*     */ 
/*     */   public void setMargin(int topMargin, int rightMargin, int bottomMargin, int leftMargin) {
/* 117 */     this.topMargin = topMargin;
/* 118 */     this.rightMargin = rightMargin;
/* 119 */     this.bottomMargin = bottomMargin;
/* 120 */     this.leftMargin = leftMargin;
/*     */   }
/*     */ 
/*     */   public DesignBand getPageHeader()
/*     */   {
/* 125 */     return this.pageHeader;
/*     */   }
/*     */ 
/*     */   public DesignBand getColumnHeader()
/*     */   {
/* 130 */     return this.columnHeader;
/*     */   }
/*     */ 
/*     */   public DesignBand getDetail()
/*     */   {
/* 135 */     return this.detail;
/*     */   }
/*     */ 
/*     */   public DesignBand getColumnFooter()
/*     */   {
/* 140 */     return this.columnFooter;
/*     */   }
/*     */ 
/*     */   public DesignBand getPageFooter()
/*     */   {
/* 145 */     return this.pageFooter;
/*     */   }
/*     */ 
/*     */   public DesignBand getSummary()
/*     */   {
/* 150 */     return this.summary;
/*     */   }
/*     */ 
/*     */   public DesignBand getBackground()
/*     */   {
/* 155 */     return this.background;
/*     */   }
/*     */ 
/*     */   public DesignBand getTitle()
/*     */   {
/* 160 */     return this.title;
/*     */   }
/*     */ 
/*     */   public DesignStyle[] getStyles()
/*     */   {
/* 165 */     DesignStyle[] arr = new DesignStyle[this.styles.size()];
/* 166 */     this.styles.toArray(arr);
/* 167 */     return arr;
/*     */   }
/*     */ 
/*     */   public void addStyle(DesignStyle style) {
/* 171 */     this.styles.add(style);
/*     */   }
/*     */ 
/*     */   public void setPaper(Paper paper) {
/* 175 */     this.paper = paper;
/* 176 */     this.pageWidth = getPixel(paper.getWidth(), 72);
/* 177 */     this.pageHeight = getPixel(paper.getHeight(), 72);
/*     */   }
/*     */ 
/*     */   public int getPixel(float mm, int DPI) {
/* 181 */     return (int)Math.round(mm / 25.399999999999999D * DPI);
/*     */   }
/*     */ 
/*     */   public void setTopMargin(int topMargin) {
/* 185 */     this.topMargin = topMargin;
/*     */   }
/*     */ 
/*     */   public void setRightMargin(int rightMargin) {
/* 189 */     this.rightMargin = rightMargin;
/*     */   }
/*     */ 
/*     */   public void setLeftMargin(int leftMargin) {
/* 193 */     this.leftMargin = leftMargin;
/*     */   }
/*     */ 
/*     */   public void setBottomMargin(int bottomMargin) {
/* 197 */     this.bottomMargin = bottomMargin;
/*     */   }
/*     */ 
/*     */   public void setPageHeader(DesignBand pageHeader) {
/* 201 */     this.pageHeader = pageHeader;
/*     */   }
/*     */ 
/*     */   public void setColumnHeader(DesignBand columnHeader) {
/* 205 */     this.columnHeader = columnHeader;
/*     */   }
/*     */ 
/*     */   public void setDetail(DesignBand detail) {
/* 209 */     this.detail = detail;
/*     */   }
/*     */ 
/*     */   public void setColumnFooter(DesignBand columnFooter) {
/* 213 */     this.columnFooter = columnFooter;
/*     */   }
/*     */ 
/*     */   public void setSummary(DesignBand summary) {
/* 217 */     this.summary = summary;
/*     */   }
/*     */ 
/*     */   public void setPageFooter(DesignBand pageFooter) {
/* 221 */     this.pageFooter = pageFooter;
/*     */   }
/*     */ 
/*     */   public void setBackground(DesignBand background) {
/* 225 */     this.background = background;
/*     */   }
/*     */ 
/*     */   public void setTitle(DesignBand title) {
/* 229 */     this.title = title;
/*     */   }
/*     */ 
/*     */   public Metadata getMetadata()
/*     */   {
/* 238 */     return this.metadata;
/*     */   }
/*     */ 
/*     */   public void setBackgroundSpan(BackgroundSpanEnum backgroundSpan) {
/* 242 */     this.backgroundSpan = backgroundSpan;
/*     */   }
/*     */ 
/*     */   public BackgroundSpanEnum getBackgroundSpan()
/*     */   {
/* 247 */     return this.backgroundSpan;
/*     */   }
/*     */ 
/*     */   public ColumnGroup getColumnGroup() {
/* 251 */     return this.columnGroup;
/*     */   }
/*     */ 
/*     */   public void setColumnGroup(DesignColumnGroup columnGroup) {
/* 255 */     this.columnGroup = columnGroup;
/*     */   }
/*     */ }

/* Location:           X:\repository\com\yss\sofa\cml\cml-api\1.1.0\cml-api-1.1.0.jar
 * Qualified Name:     com.yss.sofa.cml.design.BaseDocument
 * JD-Core Version:    0.6.0
 */